<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Skilful: Исходный файл Skilful/Data/TSymbol.cs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Создано системой Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Поиск');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Титульная&nbsp;страница</span></a></li>
      <li><a href="namespaces.html"><span>Пакеты</span></a></li>
      <li><a href="annotated.html"><span>Классы</span></a></li>
      <li class="current"><a href="files.html"><span>Файлы</span></a></li>
      <li><a href="dirs.html"><span>Алфавитный&nbsp;указатель&nbsp;директорий</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Поиск" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Файлы</span></a></li>
    </ul>
  </div>
  <div class="navpath">
    <ul>
      <li><a class="el" href="dir_7adcdc1edff7620168fbc20357cad448.html">Skilful</a>      </li>
      <li><a class="el" href="dir_c777626736fbbff11bce263deda591b3.html">Data</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<h1>TSymbol.cs</h1>  </div>
</div>
<div class="contents">
<a href="_t_symbol_8cs.html">См. документацию.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ﻿<span class="comment">//---------------------------------------------------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment">// Skilful. Tactica Adversa graphic and analysis tool.</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright (C) 2010 &quot;...&quot;, Andrey Prokhorov (AVP), Andrey Zyablitsev (skat)</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// This program is free software; you can redistribute it and/or</span>
<a name="l00006"></a>00006 <span class="comment">// modify it under the terms of the GNU General Public License</span>
<a name="l00007"></a>00007 <span class="comment">// as published by the Free Software Foundation; either version 2</span>
<a name="l00008"></a>00008 <span class="comment">// of the License, or (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with this program; if not, write to the Free Software</span>
<a name="l00017"></a>00017 <span class="comment">// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.</span>
<a name="l00018"></a>00018 <span class="comment">//</span>
<a name="l00019"></a>00019 <span class="comment">// mail: support@protoforma.com </span>
<a name="l00020"></a>00020 <span class="comment">//---------------------------------------------------------------------------------------------------------------</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">using</span> System;
<a name="l00024"></a>00024 <span class="keyword">using</span> System.Collections.Generic;
<a name="l00025"></a>00025 <span class="keyword">using</span> System.Linq;
<a name="l00026"></a>00026 <span class="keyword">using</span> System.Text;
<a name="l00027"></a>00027 <span class="keyword">using</span> System.Windows.Forms;
<a name="l00028"></a>00028 <span class="keyword">using</span> Skilful.Data;
<a name="l00029"></a>00029 <span class="keyword">using</span> ChartV2;
<a name="l00030"></a>00030 <span class="keyword">using</span> System.IO;
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="keyword">using</span> System.Reflection;
<a name="l00033"></a>00033 <span class="keyword">using</span> System.Threading;
<a name="l00034"></a>00034 <span class="keyword">using</span> System.ComponentModel;
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="keyword">namespace </span>Skilful.QuotesManager
<a name="l00038"></a>00038 {
<a name="l00039"></a><a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">00039</a>     <span class="keyword">public</span> <span class="keyword">enum</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a> { T, O, H, L, C };
<a name="l00040"></a><a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">00040</a>     <span class="keyword">public</span> <span class="keyword">enum</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a> : <span class="keywordtype">int</span>
<a name="l00041"></a>00041     {
<a name="l00042"></a>00042         m60, m240, Day, Week, Month, Quarter, Year, <span class="comment">//набор базовых фреймов</span>
<a name="l00043"></a>00043         count,                                      <span class="comment">//указатель ёмкости для массивов</span>
<a name="l00044"></a>00044         AllSeparate, AllSingle,                     <span class="comment">//наряду с базовыми флаги выбора чарта для одного симовола или набора в одном или в семи разных окнах</span>
<a name="l00045"></a>00045         custom                                      <span class="comment">//все неперечисленные тут периоды рассматриваем как определенные пользователем</span>
<a name="l00046"></a>00046     };
<a name="l00047"></a><a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">00047</a>     <span class="keyword">public</span> <span class="keyword">enum</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a> { log10, linear, mixed }; <span class="comment">//mixed -- линейный 60 и 240, логарифм от дней и выше</span>
<a name="l00048"></a>00048     
<a name="l00049"></a>00049     <span class="comment">//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//</span>
<a name="l00050"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html">00050</a>     <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html">TSymbol</a>
<a name="l00051"></a>00051     {
<a name="l00052"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a873a39f056cb34a77bde0d451fad7edd">00052</a>         <span class="keyword">public</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a> priceScale;
<a name="l00053"></a>00053         <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> DefaultChartType = <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle;
<a name="l00054"></a>00054         <a class="code" href="class_skilful_1_1_data_1_1_data_sourse_module.html">DataSourseModule</a> Module;
<a name="l00055"></a>00055         <span class="keyword">public</span> <span class="keywordtype">string</span> moduleName
<a name="l00056"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a4391c12ef4494e4b721b9a0984a60f19">00056</a>         {
<a name="l00057"></a>00057             <span class="keyword">get</span> { <span class="keywordflow">return</span> Module.name; }
<a name="l00058"></a>00058         }
<a name="l00059"></a>00059         <span class="comment">//public string SourceName;</span>
<a name="l00060"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#ae191b55c4a0e7281387943c0129c0b82">00060</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">float</span>[] TFtoHours = { 1, 4, 24, 168, 730.5f, 2191.5f, 8766 };
<a name="l00061"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a09abb6d86169b3339b2d47f17e2f4e2b">00061</a>         <span class="keyword">public</span> <span class="keywordtype">int</span> customTF;
<a name="l00062"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a8819d874656f3799a3e08da562d127bd">00062</a>         <span class="keyword">public</span> <span class="keywordtype">string</span> Name;            
<a name="l00063"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#ab6d393e51dd12a5b77c64cfa36ce032d">00063</a>         <span class="keyword">public</span> <span class="keywordtype">int</span> Decimals = 0;       
<a name="l00064"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#aad01a7a9d6441491f244d52b297b462d">00064</a>         <span class="keyword">public</span> <span class="keywordtype">double</span> pip = 0.0001;    
<a name="l00065"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a58899266fdc033e08e63b5cfec6495d8">00065</a>         <span class="keyword">public</span> <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_quotes.html" title="Класс хранит массив которивок для заданного фрейма также массивы моделей, протоформ и некоторые допол...">TQuotes</a>[,] Frames;      
<a name="l00066"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a23fdc41a3556f82b4bf05ee9dab77144">00066</a>         <span class="keyword">public</span> ModelManager.ModelTree MTree;  
<a name="l00067"></a>00067         <span class="comment">//локальные константы</span>
<a name="l00068"></a>00068         <span class="keyword">const</span> <span class="keywordtype">int</span> H1 = (int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.m60, H4 = (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.m240, D = (int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Day, W = (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Week, M = (int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Month, Q = (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Quarter, Y = (int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Year, CF =(<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.custom;
<a name="l00069"></a>00069         <span class="keyword">const</span> <span class="keywordtype">int</span> T = (int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.T, O = (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.O, H = (int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.H, L = (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.L, C = (int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.C;
<a name="l00070"></a>00070         <span class="keyword">const</span> <span class="keywordtype">int</span> candles = (<span class="keywordtype">int</span>)<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle, linear = (int)<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line, X0 = (<span class="keywordtype">int</span>)<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.X0;
<a name="l00071"></a>00071         <span class="keyword">const</span> <span class="keywordtype">int</span> NotKnownDigitsValue = 1000000;
<a name="l00072"></a>00072         <span class="keywordtype">string</span> storagePath = null, storeFileH1, storeFileD1;
<a name="l00073"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a30a272d6b27de05cec3a1cc32e535882">00073</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">event</span> <a class="code" href="namespace_skilful.html#af55054eca37e69b97a367fed9c074fa1">RefreshHistoryHandler</a> RefreshHistory;
<a name="l00074"></a>00074         <span class="keywordtype">bool</span> timeisdouble;
<a name="l00075"></a>00075         <span class="keywordtype">double</span> onehour;
<a name="l00076"></a>00076         DateTime nuldate;
<a name="l00077"></a>00077 
<a name="l00078"></a>00078         BackgroundWorker bgimporter;
<a name="l00079"></a>00079         <span class="keywordtype">double</span>[] quotes_H1=null, quotes_D1=null;
<a name="l00080"></a>00080 
<a name="l00086"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#aea5fc6dc8048f11f2d81b07e0633470d">00086</a>         <span class="keyword">public</span> <span class="keyword">static</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a> getTF(<span class="keywordtype">int</span> minutes)
<a name="l00087"></a>00087         {
<a name="l00088"></a>00088             <span class="keywordflow">if</span> (minutes &lt; 60) <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.custom;
<a name="l00089"></a>00089             <span class="keywordflow">switch</span> (minutes)
<a name="l00090"></a>00090             {
<a name="l00091"></a>00091                 <span class="keywordflow">case</span> 60:
<a name="l00092"></a>00092                     <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.m60;
<a name="l00093"></a>00093                 <span class="keywordflow">case</span> 240:
<a name="l00094"></a>00094                     <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.m240;
<a name="l00095"></a>00095                 <span class="keywordflow">case</span> 1440:
<a name="l00096"></a>00096                     <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Day;
<a name="l00097"></a>00097                 <span class="keywordflow">case</span> 10080:
<a name="l00098"></a>00098                     <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Week;
<a name="l00099"></a>00099                 <span class="keywordflow">default</span>:
<a name="l00100"></a>00100                     <span class="keywordflow">if</span> (minutes &gt;= 28 * 1440)
<a name="l00101"></a>00101                     {
<a name="l00102"></a>00102                         <span class="keywordflow">if</span> (minutes &lt;= 31 * 1440) <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Month;
<a name="l00103"></a>00103                         <span class="keywordflow">if</span> (Math.Abs(minutes - 131490) &lt; 3 * 1440) <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Quarter;
<a name="l00104"></a>00104                         if (Math.Abs(minutes - 525960) &lt; 2880) <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Year;
<a name="l00105"></a>00105                     }
<a name="l00106"></a>00106                     <span class="keywordflow">return</span> <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.custom;
<a name="l00107"></a>00107             }
<a name="l00108"></a>00108         }
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 
<a name="l00117"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a7a07c7aa624efbee4c382e6c95f70f18">00117</a>         <span class="keyword">public</span> <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html">TSymbol</a>(<a class="code" href="class_skilful_1_1_data_1_1_data_sourse_module.html">DataSourseModule</a> module, <span class="keywordtype">string</span> symbol, <a class="code" href="namespace_skilful.html#af55054eca37e69b97a367fed9c074fa1">RefreshHistoryHandler</a> QMRefreshHistory)
<a name="l00118"></a>00118         {
<a name="l00119"></a>00119             RefreshHistory = QMRefreshHistory;
<a name="l00120"></a>00120             <span class="comment">//на самом деле эти параметры нужно будет получить из пользовательскиъ настроек</span>
<a name="l00121"></a>00121             <span class="comment">//или обрабатывать события контексного меню</span>
<a name="l00122"></a>00122             <span class="comment">//scale prices: as default all graphics will be in log10</span>
<a name="l00123"></a>00123             <span class="comment">//priceScale = GlobalMembersTrend.log ? PriceScaleType.log10 : PriceScaleType.linear;</span>
<a name="l00124"></a>00124             priceScale = <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed;
<a name="l00126"></a>00126             Module = module;
<a name="l00127"></a>00127             
<a name="l00128"></a>00128             <span class="comment">//SourceName = module.name;</span>
<a name="l00129"></a>00129             Name = symbol;<span class="comment">//.ToUpper();</span>
<a name="l00130"></a>00130             
<a name="l00131"></a>00131             <span class="comment">//количество разрядов в дробноой части</span>
<a name="l00132"></a>00132             setPipValue(NotKnownDigitsValue);
<a name="l00133"></a>00133 
<a name="l00134"></a>00134             StoragePathInit();
<a name="l00135"></a>00135             Frames = <span class="keyword">new</span> <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_quotes.html" title="Класс хранит массив которивок для заданного фрейма также массивы моделей, протоформ и некоторые допол...">TQuotes</a>[(int)<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.count, (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.count];
<a name="l00136"></a>00136             <span class="keywordflow">if</span> (Module.name == <span class="stringliteral">&quot;CSV&quot;</span>)
<a name="l00137"></a>00137             {
<a name="l00138"></a>00138                 timeisdouble = <span class="keyword">true</span>;
<a name="l00139"></a>00139                 onehour = <span class="keyword">new</span> TimeSpan(TimeSpan.TicksPerHour).TotalDays;
<a name="l00140"></a>00140                 nuldate = <span class="keyword">new</span> DateTime(0001, 01, 01);
<a name="l00141"></a>00141             }
<a name="l00142"></a>00142             <span class="keywordflow">else</span>
<a name="l00143"></a>00143             {
<a name="l00144"></a>00144                 timeisdouble = <span class="keyword">false</span>;
<a name="l00145"></a>00145                 onehour = 3600;
<a name="l00146"></a>00146                 nuldate = <span class="keyword">new</span> DateTime(1970, 01, 01);
<a name="l00147"></a>00147             }
<a name="l00148"></a>00148             fillFrames1(DefaultChartType);
<a name="l00149"></a>00149 
<a name="l00150"></a>00150 
<a name="l00151"></a>00151             MTree = <span class="keyword">new</span> ModelManager.ModelTree((<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.count - 1, (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.count, <span class="keyword">this</span>);
<a name="l00152"></a>00152         }
<a name="l00153"></a>00153 
<a name="l00154"></a>00154         <span class="comment">//путь к локальной базе</span>
<a name="l00155"></a>00155         <span class="keywordtype">bool</span> StoragePathInit()
<a name="l00156"></a>00156         {
<a name="l00157"></a>00157             storagePath = Module.StoragePath;
<a name="l00158"></a>00158             <span class="keywordflow">if</span> (storagePath.Length &gt; 0)
<a name="l00159"></a>00159             {
<a name="l00160"></a>00160                 
<a name="l00161"></a>00161                 storagePath = Application.StartupPath + <span class="stringliteral">&quot;\\storage\\&quot;</span> + Module.StoragePath;
<a name="l00162"></a>00162                 <span class="keywordflow">if</span> (!Directory.Exists(storagePath)) Directory.CreateDirectory(storagePath);
<a name="l00163"></a>00163                 storeFileH1 = storagePath + <span class="charliteral">&#39;\\&#39;</span> + Name + <span class="charliteral">&#39;.&#39;</span> + (TFtoHours[H1] * 360000) + <span class="stringliteral">&quot;.qts&quot;</span>;
<a name="l00164"></a>00164                 storeFileD1 = storagePath + <span class="charliteral">&#39;\\&#39;</span> + Name + <span class="charliteral">&#39;.&#39;</span> + (TFtoHours[D] * 360000) + <span class="stringliteral">&quot;.qts&quot;</span>;
<a name="l00165"></a>00165                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00166"></a>00166             }
<a name="l00167"></a>00167             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00168"></a>00168         }
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         <span class="comment">//количество разрядов в дробноой части</span>
<a name="l00171"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#af7832f365811be20522aac9efa2026a0">00171</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> setPipValue(<span class="keywordtype">int</span> digits)
<a name="l00172"></a>00172         {
<a name="l00173"></a>00173             <span class="keywordflow">if</span> (digits == NotKnownDigitsValue)
<a name="l00174"></a>00174             {
<a name="l00175"></a>00175                 pip = Module.get_pip_value(Name);
<a name="l00176"></a>00176                 <span class="keywordflow">if</span> (pip == 0)
<a name="l00177"></a>00177                     <span class="keywordflow">if</span> (Name.ToUpper().IndexOf(<span class="stringliteral">&quot;JPY&quot;</span>) &gt;= 0) Decimals = 2;
<a name="l00178"></a>00178                     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Name.IndexOf(<span class="stringliteral">&quot;Rand&quot;</span>) &gt;= 0)
<a name="l00179"></a>00179                         Decimals = Name.Substring(Name.IndexOf(<span class="charliteral">&#39;.&#39;</span>)).Length - 1;
<a name="l00180"></a>00180                     <span class="keywordflow">else</span> Decimals = 4;
<a name="l00181"></a>00181                 <span class="keywordflow">else</span>
<a name="l00182"></a>00182                     <span class="keywordflow">for</span> (Decimals = 0; pip &lt; 1; pip *= 10) Decimals++;
<a name="l00183"></a>00183             }
<a name="l00184"></a>00184             <span class="keywordflow">else</span>
<a name="l00185"></a>00185                 Decimals = digits;
<a name="l00186"></a>00186 
<a name="l00187"></a>00187             <span class="keywordflow">if</span> (pip == 0) pip = Math.Pow(10, -Decimals);
<a name="l00188"></a>00188         }
<a name="l00189"></a>00189 
<a name="l00197"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a76bfdd92307e8c56bc9f11c57434edab">00197</a>         <span class="keyword">public</span> <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_quotes.html" title="Класс хранит массив которивок для заданного фрейма также массивы моделей, протоформ и некоторые допол...">TQuotes</a> GetQuotes(<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a> tf, <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype)
<a name="l00198"></a>00198         {
<a name="l00199"></a>00199             <span class="keywordflow">if</span> (Frames[(<span class="keywordtype">int</span>)ctype, (<span class="keywordtype">int</span>)tf] == null) fillFrames1(ctype);
<a name="l00200"></a>00200             <span class="keywordflow">return</span> Frames[(int)ctype, (<span class="keywordtype">int</span>)tf];
<a name="l00201"></a>00201         }
<a name="l00202"></a>00202 
<a name="l00203"></a>00203         <span class="comment">//------------------------------------//</span>
<a name="l00204"></a>00204         <span class="comment">//&lt;&lt; блок функций для локального хранения данных </span>
<a name="l00205"></a>00205         <span class="comment">//------------------------------------//</span>
<a name="l00206"></a>00206         <span class="comment">//------------------------------------//</span>
<a name="l00207"></a>00207         <span class="comment">//------------------------------------//</span>
<a name="l00208"></a>00208         <span class="comment">//--- read and write historical data into local database ---//</span>
<a name="l00209"></a>00209         <span class="comment">//упаковка данных для записи в файл</span>
<a name="l00210"></a>00210         <span class="keywordtype">double</span>[] qts_unpack(uint[,] package)
<a name="l00211"></a>00211         {
<a name="l00212"></a>00212             <span class="keywordtype">int</span> len = package.GetLength(0);
<a name="l00213"></a>00213             <span class="keywordtype">double</span>[] quotes = <span class="keyword">new</span> <span class="keywordtype">double</span>[len * 5];
<a name="l00214"></a>00214             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0, o = 0; i &lt; len; i++, o+=5)
<a name="l00215"></a>00215             {
<a name="l00216"></a>00216                 <span class="keywordtype">long</span> dt=0;
<a name="l00217"></a>00217                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; 4; j++)
<a name="l00218"></a>00218                 {
<a name="l00219"></a>00219                     quotes[o + j + 1] = (package[i, j] &amp; 0x00ffffff) * pip;
<a name="l00220"></a>00220                     dt |= (package[i, j] &amp; 0xff000000) &gt;&gt; (j * 8);
<a name="l00221"></a>00221                 }
<a name="l00222"></a>00222                 quotes[o] = (double)dt;
<a name="l00223"></a>00223             }
<a name="l00224"></a>00224             <span class="keywordflow">return</span> quotes;
<a name="l00225"></a>00225         }
<a name="l00226"></a>00226         <span class="comment">//распаковка данных прочитанных из локальой базы(файла)</span>
<a name="l00227"></a>00227         TQuotes qts_unpack(uint[,] package, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a> tf, <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype)
<a name="l00228"></a>00228         {
<a name="l00229"></a>00229             <span class="keywordtype">int</span> len = package.GetLength(0);
<a name="l00230"></a>00230             TQuotes quotes = <span class="keyword">new</span> TQuotes(<span class="keyword">this</span>, tf, ctype, len);
<a name="l00231"></a>00231 
<a name="l00232"></a>00232             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; len; i++)
<a name="l00233"></a>00233             {
<a name="l00234"></a>00234                 TBar bar = <span class="keyword">new</span> TBar();
<a name="l00235"></a>00235                 <span class="keywordflow">switch</span> (ctype)
<a name="l00236"></a>00236                 {
<a name="l00237"></a>00237                     <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle:
<a name="l00238"></a>00238                         <span class="keywordflow">if</span> (priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.log10 || priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed &amp;&amp; tf &gt;= <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day)
<a name="l00239"></a>00239                         {
<a name="l00240"></a>00240                             bar.Open = Math.Log10((<span class="keywordtype">double</span>)(package[i, 0] &amp; 0x00ffffff) * pip);
<a name="l00241"></a>00241                             bar.High = Math.Log10((<span class="keywordtype">double</span>)(package[i, 1] &amp; 0x00ffffff) * pip);
<a name="l00242"></a>00242                             bar.Low = Math.Log10((<span class="keywordtype">double</span>)(package[i, 2] &amp; 0x00ffffff) * pip);
<a name="l00243"></a>00243                             bar.Close = Math.Log10((<span class="keywordtype">double</span>)(package[i, 3] &amp; 0x00ffffff) * pip);
<a name="l00244"></a>00244                         }
<a name="l00245"></a>00245                         <span class="keywordflow">else</span><span class="comment">// if (priceScale == PriceScaleType.linear)</span>
<a name="l00246"></a>00246                         {
<a name="l00247"></a>00247                             bar.Open = (double)(package[i, 0] &amp; 0x00ffffff) * pip;
<a name="l00248"></a>00248                             bar.High = (double)(package[i, 1] &amp; 0x00ffffff) * pip;
<a name="l00249"></a>00249                             bar.Low = (double)(package[i, 2] &amp; 0x00ffffff) * pip;
<a name="l00250"></a>00250                             bar.Close = (double)(package[i, 3] &amp; 0x00ffffff) * pip;
<a name="l00251"></a>00251                         }
<a name="l00252"></a>00252                         <span class="keywordflow">break</span>;
<a name="l00253"></a>00253                     <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line:
<a name="l00254"></a>00254                         <span class="keywordflow">if</span> (priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.log10 || priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed &amp;&amp; tf &gt;= <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day)
<a name="l00255"></a>00255                         {
<a name="l00256"></a>00256                             bar.Open = bar.High = bar.Low = bar.Close = Math.Log10((<span class="keywordtype">double</span>)(package[i, C-O] &amp; 0x00ffffff) * pip);
<a name="l00257"></a>00257                         }
<a name="l00258"></a>00258                         <span class="keywordflow">else</span><span class="comment">// if (priceScale == PriceScaleType.linear)</span>
<a name="l00259"></a>00259                         {
<a name="l00260"></a>00260                             bar.Open = bar.High = bar.Low = bar.Close = (double)(package[i, C-O] &amp; 0x00ffffff) * pip;
<a name="l00261"></a>00261                         }
<a name="l00262"></a>00262                         <span class="keywordflow">break</span>;
<a name="l00263"></a>00263                     <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.X0:    <span class="comment">//TODO...//</span>
<a name="l00264"></a>00264                         <span class="keywordflow">break</span>;
<a name="l00265"></a>00265                 }
<a name="l00266"></a>00266                 <span class="keywordtype">long</span> dt=0;
<a name="l00267"></a>00267                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; 4; j++) dt |= package[i, j] &amp; (0xff000000 &gt;&gt; (j * 8));
<a name="l00268"></a>00268                 bar.DT = <span class="keyword">new</span> DateTime(1970, 01, 01) + TimeSpan.FromSeconds(dt);
<a name="l00269"></a>00269                 quotes.Add(bar);
<a name="l00270"></a>00270             }
<a name="l00271"></a>00271             <span class="keywordflow">return</span> quotes;
<a name="l00272"></a>00272         }
<a name="l00273"></a>00273         uint[,] qts_pack(<span class="keywordtype">double</span>[] quotes)
<a name="l00274"></a>00274         {
<a name="l00275"></a>00275             <span class="keywordtype">int</span> len = quotes.Length/5;
<a name="l00276"></a>00276             uint[,] <span class="keyword">package </span>= new uint [len,4];
<a name="l00277"></a>00277 
<a name="l00278"></a>00278             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0, o = 0; o &lt; len; i += 5, o++)
<a name="l00279"></a>00279             {
<a name="l00280"></a>00280                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0; j&lt;4; j++)
<a name="l00281"></a>00281                 {
<a name="l00282"></a>00282                     package[o, j] = (uint)(quotes[i + j + 1] / pip) | (((uint)quotes[i]&lt;&lt;(j*8)) &amp; 0xff000000);
<a name="l00283"></a>00283                 }
<a name="l00284"></a>00284             }
<a name="l00285"></a>00285             <span class="keywordflow">return</span> package;
<a name="l00286"></a>00286         }
<a name="l00287"></a>00287         <span class="comment">//существует ли локальный файл данных</span>
<a name="l00288"></a>00288         <span class="keywordtype">bool</span> ExistStoredData(<span class="keywordtype">string</span> fname)
<a name="l00289"></a>00289         {
<a name="l00290"></a>00290             <span class="keywordflow">return</span> storagePath != null &amp;&amp; File.Exists(fname);
<a name="l00291"></a>00291         }
<a name="l00292"></a>00292 
<a name="l00299"></a>00299         <span class="keywordtype">void</span> get_data(ref <span class="keywordtype">double</span>[] quotes_h1, ref <span class="keywordtype">double</span>[] quotes_d1)
<a name="l00300"></a>00300         {
<a name="l00301"></a>00301             <span class="keywordflow">if</span> (StoragePathInit())
<a name="l00302"></a>00302             {
<a name="l00303"></a>00303                 <span class="keywordflow">if</span> (ExistStoredData(storeFileH1))
<a name="l00304"></a>00304                 {
<a name="l00305"></a>00305                     uint start_time, end_time;
<a name="l00306"></a>00306                     <span class="comment">//readLocal</span>
<a name="l00307"></a>00307                     quotes_h1 = qts_unpack(qts_read(storeFileH1, out start_time, out end_time));
<a name="l00308"></a>00308                     <span class="comment">//importTail</span>
<a name="l00309"></a>00309                     Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.m60, (<span class="keywordtype">int</span>)end_time, 0);
<a name="l00310"></a>00310                     <span class="comment">//quotes_h1.Concat(Module.import(Name, TF.m60, (int)end_time, 0));</span>
<a name="l00311"></a>00311                     <span class="comment">//storeTail</span>
<a name="l00313"></a>00313 <span class="comment"></span>                    <span class="keywordflow">if</span> (ExistStoredData(storeFileD1))
<a name="l00314"></a>00314                     {
<a name="l00315"></a>00315                         <span class="comment">//readLocal</span>
<a name="l00316"></a>00316                         quotes_d1 = qts_unpack(qts_read(storeFileD1, out start_time, out end_time));
<a name="l00317"></a>00317                         <span class="comment">//importTail</span>
<a name="l00318"></a>00318                         Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day, (<span class="keywordtype">int</span>)end_time, 0);
<a name="l00319"></a>00319                         <span class="comment">//quotes_d1.Concat(Module.import(Name, TF.Day, (int)end_time, 0));</span>
<a name="l00320"></a>00320                         <span class="comment">//storeTail</span>
<a name="l00322"></a>00322 <span class="comment"></span>                    }
<a name="l00323"></a>00323                 }
<a name="l00324"></a>00324                 <span class="keywordflow">else</span>
<a name="l00325"></a>00325                 {
<a name="l00326"></a>00326                     quotes_h1 = Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.m60);                <span class="comment">//1. попытка получить часовую историю</span>
<a name="l00327"></a>00327                     <span class="comment">//if (quotes_h1 == null || quotes_h1.Length &lt; 5) quotes_h1 = Module.import(Name); //2. если нет часовой - попытка получить то что дают</span>
<a name="l00328"></a>00328                     <span class="comment">//else </span>
<a name="l00329"></a>00329                     <span class="keywordflow">if</span> (quotes_h1 != null)  quotes_d1 = Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day);           <span class="comment">//4. запрос дневной истории если есть часовая</span>
<a name="l00330"></a>00330                     <span class="comment">//store</span>
<a name="l00331"></a>00331                     <span class="keywordflow">if</span> (quotes_h1 != null &amp;&amp; quotes_h1.Length &gt;= 5 &amp;&amp; quotes_h1[0] &gt; 0) qts_write(storeFileH1, qts_pack(quotes_h1));
<a name="l00332"></a>00332                     <span class="keywordflow">if</span> (quotes_d1 != null &amp;&amp; quotes_d1.Length &gt;= 5 &amp;&amp; quotes_d1[0] &gt; 0) qts_write(storeFileD1, qts_pack(quotes_d1));
<a name="l00333"></a>00333                 }
<a name="l00334"></a>00334             }
<a name="l00335"></a>00335             <span class="keywordflow">else</span>
<a name="l00336"></a>00336             {
<a name="l00337"></a>00337                 quotes_h1 = Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.m60);                <span class="comment">//1. попытка получить часовую историю</span>
<a name="l00338"></a>00338                 <span class="keywordflow">if</span> (quotes_h1 == null || quotes_h1.Length &lt; 5) quotes_h1 = Module.import(Name); <span class="comment">//2. если нет часовой - попытка получить то что дают</span>
<a name="l00339"></a>00339                 <span class="keywordflow">else</span> quotes_d1 = Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day);           <span class="comment">//4. запрос дневной истории если есть часовая</span>
<a name="l00340"></a>00340             }
<a name="l00341"></a>00341         }
<a name="l00342"></a>00342 
<a name="l00343"></a>00343         <span class="comment">// чтение данных из файла</span>
<a name="l00344"></a>00344         uint[,] qts_read(<span class="keywordtype">string</span> fname)
<a name="l00345"></a>00345         {
<a name="l00346"></a>00346             uint start_time=0, end_time=0;
<a name="l00347"></a>00347             <span class="keywordflow">return</span> qts_read(fname, out start_time, out end_time);
<a name="l00348"></a>00348         }
<a name="l00349"></a>00349         <span class="comment">//запись данных в файл</span>
<a name="l00350"></a>00350         <span class="keywordtype">int</span> qts_write(<span class="keywordtype">string</span> fname, uint[,] package)
<a name="l00351"></a>00351         {
<a name="l00352"></a>00352             <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a> tf = <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.custom;
<a name="l00353"></a>00353             uint start_time=0, end_time=0;
<a name="l00354"></a>00354             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; 4; j++)
<a name="l00355"></a>00355             {
<a name="l00356"></a>00356                 start_time |= (package[0, j] &amp; 0xff000000) &gt;&gt; (j * 8);
<a name="l00357"></a>00357                 end_time |= (package[package.GetLength(0) - 1, j] &amp; 0xff000000) &gt;&gt; (j * 8);
<a name="l00358"></a>00358             }
<a name="l00359"></a>00359             <span class="keywordflow">return</span> qts_write(fname, tf, package, start_time, end_time);
<a name="l00360"></a>00360         }
<a name="l00361"></a>00361         uint[,] qts_read(<span class="keywordtype">string</span> fname, out uint start_time, out uint end_time)
<a name="l00362"></a>00362         {
<a name="l00363"></a>00363             uint[,] pckg=null;
<a name="l00364"></a>00364             start_time = end_time = 0;
<a name="l00365"></a>00365             <span class="keywordflow">if</span> (File.Exists(fname))
<a name="l00366"></a>00366             {
<a name="l00367"></a>00367                 <span class="comment">// Create the reader for data.</span>
<a name="l00368"></a>00368                 FileStream fs = <span class="keyword">new</span> FileStream(fname, FileMode.Open, FileAccess.Read);
<a name="l00369"></a>00369                 BinaryReader r = <span class="keyword">new</span> BinaryReader(fs);
<a name="l00370"></a>00370                 <span class="comment">// Read data from Test.data.</span>
<a name="l00371"></a>00371                 <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a> tf = (TF) r.ReadInt32();   <span class="comment">//period as enum TF (хотя фрейм присутствует в имени файла)</span>
<a name="l00372"></a>00372                 start_time = r.ReadUInt32();  <span class="comment">//time of first bar in file</span>
<a name="l00373"></a>00373                 end_time = r.ReadUInt32();    <span class="comment">//time of last bar in file</span>
<a name="l00374"></a>00374                 <span class="keywordtype">int</span> len = r.ReadInt32();      <span class="comment">//number of bars</span>
<a name="l00375"></a>00375                 r.ReadBytes(16);              <span class="comment">//reserved</span>
<a name="l00376"></a>00376                 <span class="comment">//read array</span>
<a name="l00377"></a>00377                 pckg = <span class="keyword">new</span> uint[len, 4];
<a name="l00378"></a>00378                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; len; i++)
<a name="l00379"></a>00379                     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; 4; j++)
<a name="l00380"></a>00380                         pckg[i, j] = r.ReadUInt32();
<a name="l00381"></a>00381                 r.Close();
<a name="l00382"></a>00382                 fs.Close();
<a name="l00383"></a>00383                 <span class="comment">//r.ReadBytes(len * 4);</span>
<a name="l00384"></a>00384             }
<a name="l00385"></a>00385             <span class="keywordflow">return</span> pckg;
<a name="l00386"></a>00386         }
<a name="l00387"></a>00387         <span class="keywordtype">int</span> qts_write(<span class="keywordtype">string</span> fname, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a> tf, uint[,] package, uint start_time, uint end_time)
<a name="l00388"></a>00388         {
<a name="l00389"></a>00389             FileStream fs = <span class="keyword">new</span> FileStream(fname, FileMode.OpenOrCreate);
<a name="l00390"></a>00390             <span class="comment">// Create the writer for data.</span>
<a name="l00391"></a>00391             BinaryWriter w = <span class="keyword">new</span> BinaryWriter(fs);
<a name="l00392"></a>00392             <span class="comment">// Write data to Test.data.</span>
<a name="l00393"></a>00393             <span class="keywordtype">int</span> i = 0, j = 0;
<a name="l00394"></a>00394             <span class="keywordflow">try</span>
<a name="l00395"></a>00395             {
<a name="l00396"></a>00396                 w.Write((<span class="keywordtype">int</span>)tf);              <span class="comment">//period as enum TF (хотя фрейм присутствует в имени файла)</span>
<a name="l00397"></a>00397                 w.Write(start_time);           <span class="comment">//time of first bar in file</span>
<a name="l00398"></a>00398                 w.Write(end_time);             <span class="comment">//time of last bar in file</span>
<a name="l00399"></a>00399                 w.Write(package.GetLength(0)); <span class="comment">//number of bars</span>
<a name="l00400"></a>00400                 w.Write(<span class="keyword">new</span> byte[16]);         <span class="comment">//reserved</span>
<a name="l00401"></a>00401                 <span class="comment">//write data array</span>
<a name="l00402"></a>00402                 <span class="keywordflow">for</span> (i=0; i &lt; package.GetLength(0); i++)
<a name="l00403"></a>00403                     <span class="keywordflow">for</span> (j=0; j &lt; package.GetLength(1); j++)
<a name="l00404"></a>00404                         w.Write(package[i, j]);
<a name="l00405"></a>00405                 w.Close();
<a name="l00406"></a>00406                 fs.Close();
<a name="l00407"></a>00407             }
<a name="l00408"></a>00408             <span class="keywordflow">catch</span> (Exception e)
<a name="l00409"></a>00409             {
<a name="l00410"></a>00410                 MessageBox.Show(e.Message);
<a name="l00411"></a>00411                 w.Close();
<a name="l00412"></a>00412                 fs.Dispose();
<a name="l00413"></a>00413             }
<a name="l00414"></a>00414             <span class="keywordflow">return</span> i * package.GetLength(1) + j;
<a name="l00415"></a>00415         }
<a name="l00416"></a>00416         
<a name="l00417"></a>00417         <span class="comment">//импорт данных в отдельном потоке</span>
<a name="l00418"></a>00418         <span class="keywordtype">void</span> bgimporter_start(<span class="keywordtype">object</span> sender, DoWorkEventArgs e)
<a name="l00419"></a>00419         {
<a name="l00420"></a>00420             quotes_H1 = null;
<a name="l00421"></a>00421             get_data(ref quotes_H1, ref quotes_D1);
<a name="l00422"></a>00422         }
<a name="l00423"></a>00423         <span class="keywordtype">void</span> bgimporter_complete(<span class="keywordtype">object</span> sender, RunWorkerCompletedEventArgs e)
<a name="l00424"></a>00424         {
<a name="l00425"></a>00425             <span class="keywordflow">if</span> (quotes_H1 == null || quotes_H1.Length &lt; 5) <span class="keywordflow">return</span>;
<a name="l00426"></a>00426             <span class="keywordflow">switch</span> (DefaultChartType)<span class="comment">//default: DefaultChartType is Candles</span>
<a name="l00427"></a>00427             {
<a name="l00428"></a>00428                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle:
<a name="l00429"></a>00429                     fillFramesCandle(quotes_H1, quotes_D1);
<a name="l00430"></a>00430                     <span class="keywordflow">break</span>;
<a name="l00431"></a>00431                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line:
<a name="l00432"></a>00432                     fillFramesLine(quotes_H1, quotes_D1);
<a name="l00433"></a>00433                     <span class="keywordflow">break</span>;
<a name="l00434"></a>00434                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.X0:
<a name="l00435"></a>00435                     <span class="comment">//fillFramesX0(quotes);</span>
<a name="l00436"></a>00436                     <span class="keywordflow">break</span>;
<a name="l00437"></a>00437             }
<a name="l00438"></a>00438             <span class="keywordflow">if</span> (RefreshHistory != null) RefreshHistory(moduleName, Name);
<a name="l00439"></a>00439         }
<a name="l00440"></a>00440         <span class="keywordtype">void</span> bgimport(<span class="keywordtype">object</span> sender, DoWorkEventArgs e)
<a name="l00441"></a>00441         {
<a name="l00442"></a>00442             quotes_H1 = null;
<a name="l00443"></a>00443         }
<a name="l00444"></a>00444         <span class="keywordtype">void</span> fillFrames1(<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype)
<a name="l00445"></a>00445         {
<a name="l00446"></a>00446             <span class="keywordtype">double</span>[] quotes_h1={0,0,0,0,0}, quotes_d1 = null;
<a name="l00447"></a>00447 
<a name="l00448"></a>00448             <span class="keywordflow">if</span> (moduleName != <span class="stringliteral">&quot;Dukascopy&quot;</span>)
<a name="l00449"></a>00449                 get_data(ref quotes_h1, ref quotes_d1);<span class="comment">//get_data перевести в бэкграунд\</span>
<a name="l00450"></a>00450 <span class="comment">            else</span>
<a name="l00451"></a>00451             {
<a name="l00452"></a>00452                 bgimporter = <span class="keyword">new</span> BackgroundWorker();
<a name="l00453"></a>00453                 bgimporter.WorkerSupportsCancellation = <span class="keyword">true</span>;
<a name="l00454"></a>00454                 bgimporter.DoWork += bgimporter_start;
<a name="l00455"></a>00455                 bgimporter.RunWorkerCompleted += bgimporter_complete;
<a name="l00456"></a>00456                 bgimporter.RunWorkerAsync(ctype);
<a name="l00457"></a>00457             }
<a name="l00458"></a>00458             
<a name="l00459"></a>00459             <span class="keywordflow">if</span> (quotes_h1 == null || quotes_h1.Length &lt; 5) <span class="keywordflow">return</span>;
<a name="l00460"></a>00460 
<a name="l00461"></a>00461             <span class="keywordflow">switch</span> (ctype)
<a name="l00462"></a>00462             {
<a name="l00463"></a>00463                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle:
<a name="l00464"></a>00464                     fillFramesCandle(quotes_h1, quotes_d1);
<a name="l00465"></a>00465                     <span class="keywordflow">break</span>;
<a name="l00466"></a>00466                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line:
<a name="l00467"></a>00467                     fillFramesLine(quotes_h1, quotes_d1);
<a name="l00468"></a>00468                     <span class="keywordflow">break</span>;
<a name="l00469"></a>00469                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.X0:
<a name="l00470"></a>00470                     <span class="comment">//fillFramesX0(quotes);</span>
<a name="l00471"></a>00471                     <span class="keywordflow">break</span>;
<a name="l00472"></a>00472             }
<a name="l00473"></a>00473         }
<a name="l00474"></a>00474         <span class="comment">//------------------------------------//</span>
<a name="l00475"></a>00475         <span class="comment">// блок функций для локального хранения данных &gt;&gt;</span>
<a name="l00476"></a>00476         <span class="comment">//------------------------------------//</span>
<a name="l00477"></a>00477         <span class="comment">//------------------------------------//</span>
<a name="l00478"></a>00478         <span class="comment">//------------------------------------//</span>
<a name="l00479"></a>00479 
<a name="l00484"></a>00484         <span class="keywordtype">void</span> fillFrames(<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype)
<a name="l00485"></a>00485         {
<a name="l00486"></a>00486             <span class="keywordtype">double</span>[] quotes_d1 = null,
<a name="l00487"></a>00487                      quotes_h1 = Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.m60);       <span class="comment">//1. попытка получить часовую историю</span>
<a name="l00488"></a>00488             <span class="keywordflow">if</span> (quotes_h1 == null) quotes_h1 = Module.import(Name); <span class="comment">//2. если нет часовой - попытка получить то что дают</span>
<a name="l00489"></a>00489             <span class="keywordflow">else</span> quotes_d1 = Module.import(Name, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day);           <span class="comment">//4. запрос дневной истории если есть часовая</span>
<a name="l00490"></a>00490 
<a name="l00491"></a>00491             <span class="keywordflow">switch</span> (ctype)
<a name="l00492"></a>00492             {
<a name="l00493"></a>00493                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle:
<a name="l00494"></a>00494                     fillFramesCandle(quotes_h1, quotes_d1);
<a name="l00495"></a>00495                     <span class="keywordflow">break</span>;
<a name="l00496"></a>00496                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line:
<a name="l00497"></a>00497                     fillFramesLine(quotes_h1, quotes_d1);
<a name="l00498"></a>00498                     <span class="keywordflow">break</span>;
<a name="l00499"></a>00499                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.X0:
<a name="l00500"></a>00500                     <span class="comment">//fillFramesX0(quotes);</span>
<a name="l00501"></a>00501                     <span class="keywordflow">break</span>;
<a name="l00502"></a>00502             }
<a name="l00503"></a>00503         }
<a name="l00504"></a>00504 
<a name="l00510"></a>00510         TBar log(TBar bar)
<a name="l00511"></a>00511         {
<a name="l00512"></a>00512             bar.Open = Math.Log10(bar.Open);
<a name="l00513"></a>00513             bar.High = Math.Log10(bar.High);
<a name="l00514"></a>00514             bar.Low = Math.Log10(bar.Low);
<a name="l00515"></a>00515             bar.Close = Math.Log10(bar.Close);
<a name="l00516"></a>00516             <span class="keywordflow">return</span> bar;
<a name="l00517"></a>00517         }
<a name="l00518"></a>00518 
<a name="l00524"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#a52291e6cdc34ec53005d4635eb7157a5">00524</a>         <span class="keyword">public</span> <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html">TBar</a> darr2TBar(<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a> frame, <span class="keywordtype">double</span>[] quotes, <span class="keywordtype">int</span> bar_idx, <span class="keywordtype">int</span> i)
<a name="l00525"></a>00525         {
<a name="l00526"></a>00526             <span class="keywordflow">for</span> (<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype = 0; ctype &lt; <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.count; ctype++)
<a name="l00527"></a>00527                 <span class="keywordflow">if</span> (Frames[(<span class="keywordtype">int</span>)ctype, (<span class="keywordtype">int</span>)frame] != null)
<a name="l00528"></a>00528                     <span class="keywordflow">return</span> darr2TBar(ctype, frame, quotes, bar_idx, i);
<a name="l00529"></a>00529             <span class="keywordflow">return</span> null;
<a name="l00530"></a>00530         }
<a name="l00531"></a>00531         
<a name="l00543"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#adbfb8fff312229483b0102edde48e89e">00543</a>         <span class="keyword">public</span> <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html">TBar</a> darr2TBar(<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype, <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a> frame, <span class="keywordtype">double</span>[] quotes, <span class="keywordtype">int</span> bar_idx, <span class="keywordtype">int</span> i)
<a name="l00544"></a>00544         {
<a name="l00545"></a>00545             <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html">TBar</a> b = <span class="keyword">new</span> <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html">TBar</a>();
<a name="l00546"></a>00546             b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a95b63ff50e74424a72e935daffc881ff" title="№ бара">Bar</a> = b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#adcbdc1a8be868cc0d51d6ac30e9521a6" title="№ бара на исходном ТФ с которого начинается этот бар">X</a> = bar_idx &gt;= 0 ? bar_idx : Frames[(int)ctype, (<span class="keywordtype">int</span>)frame].GetCount();
<a name="l00547"></a>00547             <span class="keywordflow">switch</span> (ctype)
<a name="l00548"></a>00548             {
<a name="l00549"></a>00549                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle:
<a name="l00550"></a>00550                     <span class="keywordflow">if</span> (priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.log10 || priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed &amp;&amp; frame&gt;=<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Day)
<a name="l00551"></a>00551                     {
<a name="l00552"></a>00552                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a7d02ebdc7bb8a313c1a8347f94febb50" title="Цена открытия.">Open</a> = Math.Log10((<span class="keywordtype">double</span>)GlobalMembersTAmodel.round((decimal)quotes[i + O], Decimals));
<a name="l00553"></a>00553                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a> = Math.Log10((<span class="keywordtype">double</span>)GlobalMembersTAmodel.round((decimal)quotes[i + H], Decimals));
<a name="l00554"></a>00554                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a> = Math.Log10((<span class="keywordtype">double</span>)GlobalMembersTAmodel.round((decimal)quotes[i + L], Decimals));
<a name="l00555"></a>00555                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a> = Math.Log10((<span class="keywordtype">double</span>)GlobalMembersTAmodel.round((decimal)quotes[i + C], Decimals));
<a name="l00556"></a>00556                     }
<a name="l00557"></a>00557                     <span class="keywordflow">else</span><span class="comment">// if (priceScale == PriceScaleType.linear)</span>
<a name="l00558"></a>00558                     {
<a name="l00559"></a>00559                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a7d02ebdc7bb8a313c1a8347f94febb50" title="Цена открытия.">Open</a> = (double)GlobalMembersTAmodel.round((decimal)quotes[i + O], Decimals);
<a name="l00560"></a>00560                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a> = (double)GlobalMembersTAmodel.round((decimal)quotes[i + H], Decimals);
<a name="l00561"></a>00561                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a> = (double)GlobalMembersTAmodel.round((decimal)quotes[i + L], Decimals);
<a name="l00562"></a>00562                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a> = (double)GlobalMembersTAmodel.round((decimal)quotes[i + C], Decimals);
<a name="l00563"></a>00563                     }
<a name="l00564"></a>00564                     <span class="keywordflow">goto</span> gen;
<a name="l00565"></a>00565                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line:
<a name="l00566"></a>00566                     <span class="keywordflow">if</span> (priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.log10 || priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed &amp;&amp; frame &gt;= <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.Day)
<a name="l00567"></a>00567                     {
<a name="l00568"></a>00568                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a7d02ebdc7bb8a313c1a8347f94febb50" title="Цена открытия.">Open</a> = b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a> = b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a> = b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a> = Math.Log10((<span class="keywordtype">double</span>)GlobalMembersTAmodel.round((decimal)quotes[i + C], Decimals));
<a name="l00569"></a>00569                     }
<a name="l00570"></a>00570                     <span class="keywordflow">else</span><span class="comment">// if (priceScale == PriceScaleType.linear)</span>
<a name="l00571"></a>00571                     {
<a name="l00572"></a>00572                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a7d02ebdc7bb8a313c1a8347f94febb50" title="Цена открытия.">Open</a> = b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a> = b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a> = b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a> = (double)GlobalMembersTAmodel.round((decimal)quotes[i + C], Decimals);
<a name="l00573"></a>00573                     }
<a name="l00574"></a>00574                 gen:
<a name="l00575"></a>00575                     <span class="comment">//general code for both Candle and Linear ChartTypes</span>
<a name="l00576"></a>00576                     <span class="keywordflow">if</span>(timeisdouble)
<a name="l00577"></a>00577                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a> = nuldate + TimeSpan.FromDays(quotes[i + (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.T]);
<a name="l00578"></a>00578                     <span class="keywordflow">else</span>
<a name="l00579"></a>00579                         b.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a> = nuldate + TimeSpan.FromSeconds((uint)quotes[i + (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.T]);
<a name="l00580"></a>00580                     
<a name="l00581"></a>00581                     <span class="comment">// bar_idx = -1: добавление единичного бара в конец списка</span>
<a name="l00582"></a>00582                     <span class="comment">// bar_idx = -2: не включается в список</span>
<a name="l00583"></a>00583                     <span class="keywordflow">if</span> (bar_idx &gt;= -1)
<a name="l00584"></a>00584                         Frames[(int)ctype, (<span class="keywordtype">int</span>)frame].Add(b);
<a name="l00585"></a>00585                     <span class="keywordflow">return</span> b;
<a name="l00586"></a>00586                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.X0:    <span class="comment">//TODO...//</span>
<a name="l00587"></a>00587                     <span class="keywordflow">break</span>;
<a name="l00588"></a>00588             }
<a name="l00589"></a>00589             <span class="keywordflow">return</span> null;
<a name="l00590"></a>00590         }
<a name="l00591"></a>00591         <span class="comment">// сигнал о получении нового бара онлайн</span>
<a name="l00592"></a><a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_symbol.html#ad69417cc22a5bc2ce4e3778dd3e8aea7">00592</a>         <span class="keyword">public</span> <span class="keywordtype">int</span> NewBar(<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> chartType, <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a> sourcetimeFrame, <a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a> timeFrame, <span class="keywordtype">double</span>[] quotes)
<a name="l00593"></a>00593         {
<a name="l00594"></a>00594             <span class="keywordtype">int</span> ctype = (int)chartType, stf = (<span class="keywordtype">int</span>)sourcetimeFrame, tf = (int)timeFrame;
<a name="l00595"></a>00595             <span class="keywordflow">switch</span> (chartType)
<a name="l00596"></a>00596             {
<a name="l00597"></a>00597                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle:
<a name="l00598"></a>00598                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line:
<a name="l00599"></a>00599                     <span class="keywordflow">if</span> (Frames[ctype, tf] != null)
<a name="l00600"></a>00600                     {
<a name="l00601"></a>00601                         <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html">TBar</a> bar = darr2TBar(<a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle, timeFrame, quotes, -2, 0);
<a name="l00602"></a>00602                         <span class="comment">//откатили на предыдущий или текущий бар</span>
<a name="l00603"></a>00603                         <span class="keywordtype">int</span> i = Frames[ctype, tf].lastindex;
<a name="l00604"></a>00604                         <span class="keywordflow">while</span> (Frames[ctype, tf][i].DT &gt; bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a>) i--;
<a name="l00605"></a>00605                         DateTime dt = Gen.incTime(Frames[ctype, tf][i].DT, timeFrame);
<a name="l00606"></a>00606                         <span class="comment">//новый бар</span>
<a name="l00607"></a>00607                         <span class="keywordflow">if</span> (dt &lt;= bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a>)
<a name="l00608"></a>00608                         {
<a name="l00609"></a>00609                             <span class="keywordflow">while</span> ((dt = Gen.incTime(dt, timeFrame)) &lt;= bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a>) ;
<a name="l00610"></a>00610                             bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a> = Gen.decTime(dt, timeFrame);
<a name="l00611"></a>00611                             Frames[ctype, tf].Quotes.Insert(++i, bar);
<a name="l00612"></a>00612                             <span class="keywordflow">return</span> i;
<a name="l00613"></a>00613                         }
<a name="l00614"></a>00614                         <span class="comment">//заполняем текущий бар</span>
<a name="l00615"></a>00615                         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dt &gt; bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a>)
<a name="l00616"></a>00616                         {
<a name="l00617"></a>00617                             <a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html">TBar</a> last = Frames[ctype, tf][i];
<a name="l00618"></a>00618 
<a name="l00619"></a>00619                             <span class="keywordflow">if</span> (chartType == <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle)
<a name="l00620"></a>00620                             {
<a name="l00621"></a>00621                                 <span class="keywordflow">if</span> (Frames[ctype, tf][i].DT == bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#afb591f6c3317e17698c7912ba4fc3bdd" title="Дата/время бара.">DT</a>) last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a7d02ebdc7bb8a313c1a8347f94febb50" title="Цена открытия.">Open</a> = bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a7d02ebdc7bb8a313c1a8347f94febb50" title="Цена открытия.">Open</a>;<span class="comment">//обновление Опен только если время oткрытия бара совпадает со временем открытия на данном фрейме</span>
<a name="l00622"></a>00622                                 <span class="keywordflow">if</span> (last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a> &lt; bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a>) last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a> = bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a>;
<a name="l00623"></a>00623                                 <span class="keywordflow">if</span> (last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a> &gt; bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a>) last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a> = bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a>;
<a name="l00624"></a>00624                                 last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a> = bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a>;
<a name="l00625"></a>00625                             }<span class="keywordflow">else</span>{ <span class="comment">//if (chartType == ChartType.Linear)</span>
<a name="l00626"></a>00626                                 last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a7d02ebdc7bb8a313c1a8347f94febb50" title="Цена открытия.">Open</a> = last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a710d6cdb43bf580f28cba814c07cad23" title="Цена макс.">High</a> = last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#ad5290255d4271f7d582c64e1772e4519" title="Цена мин.">Low</a> = last.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a> = bar.<a class="code" href="class_skilful_1_1_quotes_manager_1_1_t_bar.html#a914b7de2dbf4218bcf884c037596a98f" title="Цена закрытия.">Close</a>;
<a name="l00627"></a>00627                             }
<a name="l00628"></a>00628                             
<a name="l00629"></a>00629                             <span class="keywordflow">return</span> i;
<a name="l00630"></a>00630                         }
<a name="l00631"></a>00631                     }
<a name="l00632"></a>00632                     <span class="keywordflow">break</span>;
<a name="l00633"></a>00633                 <span class="keywordflow">case</span> <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.X0:
<a name="l00634"></a>00634                     <span class="comment">//TODO</span>
<a name="l00635"></a>00635                     <span class="keywordflow">break</span>;
<a name="l00636"></a>00636             }
<a name="l00637"></a>00637             <span class="keywordflow">return</span> -1;
<a name="l00638"></a>00638         }
<a name="l00639"></a>00639 
<a name="l00646"></a>00646         <span class="keywordtype">void</span> fillFramesCandle(<span class="keywordtype">double</span>[] quotes_h1, <span class="keywordtype">double</span>[] quotes_d1)
<a name="l00647"></a>00647         {
<a name="l00648"></a>00648             <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype = <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle;
<a name="l00649"></a>00649             <span class="keywordtype">int</span> ct = (int)ctype;
<a name="l00650"></a>00650             <span class="keywordtype">double</span>[] time_next = <span class="keyword">new</span> <span class="keywordtype">double</span>[(int)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#a5c84c6ba01636871f8f98492b465c315">TF</a>.count], qts = {0,0,0,0,0};
<a name="l00651"></a>00651             <span class="keywordflow">if</span>(quotes_h1 != null &amp;&amp; quotes_h1.Length&gt;=5)
<a name="l00652"></a>00652                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i&lt;5; i++)
<a name="l00653"></a>00653                     qts[i] = quotes_h1[i];
<a name="l00654"></a>00654             <span class="comment">//base 60min plan</span>
<a name="l00655"></a>00655             <span class="keywordflow">if</span> (Frames[ct, H1] == null) Frames[ct, H1] = <span class="keyword">new</span> TQuotes(<span class="keyword">this</span>, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.m60, ctype, quotes_h1.Length / 5);
<a name="l00656"></a>00656             <span class="keywordflow">else</span>  Frames[ct, H1].Resize(quotes_h1.Length / 5);
<a name="l00657"></a>00657             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0, j = 0, q = 0; i &lt; quotes_h1.Length / 5 &amp;&amp; quotes_h1[j] &gt; 0; i++, j += 5) <span class="comment">//set real index of bar in double[] quotes_h1 array</span>
<a name="l00658"></a>00658             {
<a name="l00659"></a>00659                 <span class="comment">//Итак решено собирать часовые фреймы из любых исходных</span>
<a name="l00660"></a>00660                 <span class="keywordflow">if</span> (quotes_h1[j+T] &gt;= time_next[H1])
<a name="l00661"></a>00661                 {
<a name="l00662"></a>00662                     darr2TBar(ctype, H1, qts, q++, 0);
<a name="l00663"></a>00663                     qts[T] = quotes_h1[j + T];
<a name="l00664"></a>00664                     qts[O] = quotes_h1[j + O];
<a name="l00665"></a>00665                     qts[H] = quotes_h1[j + H];
<a name="l00666"></a>00666                     qts[L] = quotes_h1[j + L];
<a name="l00667"></a>00667                     qts[C] = quotes_h1[j + C];
<a name="l00668"></a>00668                     time_next[H1] = qts[T] + onehour; <span class="comment">//3600 sec == 1 hour</span>
<a name="l00669"></a>00669                 }
<a name="l00670"></a>00670                 <span class="keywordflow">else</span>
<a name="l00671"></a>00671                 {
<a name="l00672"></a>00672                     <span class="keywordflow">if</span>(qts[H] &lt; quotes_h1[j + H]) qts[H] = quotes_h1[j + H];
<a name="l00673"></a>00673                     <span class="keywordflow">if</span>(qts[L] &gt; quotes_h1[j + L]) qts[L] = quotes_h1[j + L] ;
<a name="l00674"></a>00674                     qts[C] = quotes_h1[j + C];
<a name="l00675"></a>00675                 }
<a name="l00676"></a>00676             }
<a name="l00677"></a>00677             darr2TBar(ctype, H1, qts, -1, 0);
<a name="l00678"></a>00678 
<a name="l00679"></a>00679             <span class="comment">//m240</span>
<a name="l00680"></a>00680             fillFrameCandle(H1, H4, quotes_h1.Length / 20);
<a name="l00681"></a>00681             
<a name="l00682"></a>00682             <span class="keywordflow">if</span> (quotes_d1 != null &amp;&amp; quotes_d1.Length &gt;= 5) <span class="comment">//(quotes_d1.Length &gt;  quotes_h1.Length / 100) -- актуальный размер массива при котором имеет смысл переходить на дневную истории, иначе, доступная история дневок короче чем часовая</span>
<a name="l00683"></a>00683             {
<a name="l00684"></a>00684                 <span class="comment">//берем дневную историю</span>
<a name="l00685"></a>00685                 <span class="keywordflow">if</span> (Frames[ct, D] == null) Frames[ct, D] = <span class="keyword">new</span> TQuotes(<span class="keyword">this</span>, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day, ctype, quotes_d1.Length / 5);
<a name="l00686"></a>00686                 <span class="keywordflow">else</span> Frames[ct, D].Resize(quotes_d1.Length / 5);
<a name="l00687"></a>00687 
<a name="l00688"></a>00688                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0, j = 0; i &lt; quotes_d1.Length / 5; i++, j += 5) <span class="comment">//set real index of bar in double[] quotes_h1 array</span>
<a name="l00689"></a>00689                 {
<a name="l00690"></a>00690                     darr2TBar(ctype, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day, quotes_d1, i, j);
<a name="l00691"></a>00691                 }
<a name="l00692"></a>00692             }
<a name="l00693"></a>00693             <span class="keywordflow">else</span>
<a name="l00694"></a>00694             {
<a name="l00695"></a>00695                 <span class="comment">//получаем дневную историю из 4-х часовой</span>
<a name="l00696"></a>00696                 fillFrameCandle(H4, D, quotes_h1.Length / 100);
<a name="l00697"></a>00697             }
<a name="l00698"></a>00698             <span class="comment">//weekly</span>
<a name="l00699"></a>00699             fillFrameCandle(D, W, 16);
<a name="l00700"></a>00700 
<a name="l00701"></a>00701             <span class="comment">//mongthly</span>
<a name="l00702"></a>00702             fillFrameCandle(D, M, 16);
<a name="l00703"></a>00703 
<a name="l00704"></a>00704             <span class="comment">//quarterly</span>
<a name="l00705"></a>00705             fillFrameCandle(M, Q, 16);
<a name="l00706"></a>00706 
<a name="l00707"></a>00707             <span class="comment">//yearly</span>
<a name="l00708"></a>00708             fillFrameCandle(Q, Y, 16);
<a name="l00709"></a>00709            
<a name="l00710"></a>00710             <span class="comment">//end</span>
<a name="l00711"></a>00711         }
<a name="l00712"></a>00712 
<a name="l00713"></a>00713         <span class="comment">//fillFrameCandle</span>
<a name="l00718"></a>00718 <span class="comment"></span>        <span class="keywordtype">void</span> fillFrameCandle(<span class="keywordtype">int</span> srcTF, <span class="keywordtype">int</span> destTF, <span class="keywordtype">int</span> destlen)
<a name="l00719"></a>00719         {
<a name="l00720"></a>00720             <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype = <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Candle;
<a name="l00721"></a>00721             TQuotes qsrc = Frames[(int)ctype, srcTF];
<a name="l00722"></a>00722             TQuotes qdest = Frames[(int)ctype, destTF];
<a name="l00723"></a>00723             <span class="keywordtype">bool</span> doLg = destTF == (int)<a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day &amp;&amp; priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed;
<a name="l00724"></a>00724 
<a name="l00725"></a>00725             <span class="comment">//получаем дневную историю из 4-х часовой</span>
<a name="l00726"></a>00726             if (qdest == null) qdest = <span class="keyword">new</span> TQuotes(<span class="keyword">this</span>, (<a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>)destTF, ctype, destlen<span class="comment">/*quotes_h1.Length / 100*/</span>);
<a name="l00727"></a>00727             <span class="keywordflow">else</span> qdest.Resize(destlen);
<a name="l00728"></a>00728             
<a name="l00729"></a>00729             DateTime nextBarTime = <span class="keyword">new</span> DateTime();<span class="comment">// = Gen.incTimeFloor(b.DT, destTF);</span>
<a name="l00730"></a>00730             TBar bar = <span class="keyword">new</span> TBar();
<a name="l00731"></a>00731             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0, j = 0; i &lt; qsrc.GetCount(); i++)
<a name="l00732"></a>00732             {
<a name="l00733"></a>00733                 TBar b = qsrc[i];  <span class="comment">//local alias of current bar</span>
<a name="l00734"></a>00734                 
<a name="l00735"></a>00735                 <span class="keywordflow">if</span> (i == 0 || nextBarTime &lt;= b.DT) <span class="comment">//next bar completed</span>
<a name="l00736"></a>00736                 {
<a name="l00737"></a>00737                     <span class="keywordflow">if</span> (i &gt; 0) qdest.Add(doLg ? log(bar) : bar); <span class="comment">//store existing bar</span>
<a name="l00738"></a>00738                     bar = <span class="keyword">new</span> TBar();
<a name="l00739"></a>00739                     bar.Bar = bar.X = j++;
<a name="l00740"></a>00740                     bar.Open = b.Open;
<a name="l00741"></a>00741                     bar.High = b.High;
<a name="l00742"></a>00742                     bar.Low = b.Low;
<a name="l00743"></a>00743                     bar.Close = b.Close;
<a name="l00744"></a>00744                     bar.DT = b.DT;
<a name="l00745"></a>00745                     nextBarTime = Gen.incTimeFloor(b.DT, (<a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>)destTF);
<a name="l00746"></a>00746                 }
<a name="l00747"></a>00747                 <span class="keywordflow">else</span>
<a name="l00748"></a>00748                 {
<a name="l00749"></a>00749                     <span class="keywordflow">if</span> (bar.High &lt; b.High) bar.High = b.High;
<a name="l00750"></a>00750                     <span class="keywordflow">if</span> (bar.Low &gt; b.Low) bar.Low = b.Low;
<a name="l00751"></a>00751                     bar.Close = b.Close;
<a name="l00752"></a>00752                 }
<a name="l00753"></a>00753             }
<a name="l00754"></a>00754             qdest.Add(doLg ? log(bar) : bar); <span class="comment">//store last, possible none completed bar</span>
<a name="l00755"></a>00755             Frames[(int)ctype, destTF] = qdest;
<a name="l00756"></a>00756         }
<a name="l00757"></a>00757 
<a name="l00758"></a>00758         <span class="comment">//fillFrameLine</span>
<a name="l00764"></a>00764 <span class="comment"></span>        <span class="keywordtype">void</span> fillFrameLine(<span class="keywordtype">int</span> srcTF, <span class="keywordtype">int</span> destTF)
<a name="l00765"></a>00765         {
<a name="l00766"></a>00766             <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype = <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line;
<a name="l00767"></a>00767             TQuotes qsrc = Frames[(int)ctype, srcTF];
<a name="l00768"></a>00768             TQuotes qdest = <span class="keyword">new</span> TQuotes(<span class="keyword">this</span>, (<a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>)destTF, ctype);
<a name="l00769"></a>00769             <span class="keywordtype">bool</span> doLg = destTF == (int)<a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day &amp;&amp; priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed;
<a name="l00770"></a>00770 
<a name="l00771"></a>00771             DateTime nextBarTime = <span class="keyword">new</span> DateTime();<span class="comment">// = Gen.incTimeFloor(b.DT, destTF);</span>
<a name="l00772"></a>00772             TBar bar = <span class="keyword">new</span> TBar();
<a name="l00773"></a>00773 
<a name="l00774"></a>00774             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0, j = 0; i &lt; qsrc.GetCount(); i++)
<a name="l00775"></a>00775             {
<a name="l00776"></a>00776                 <span class="keywordflow">if</span> (i == 0 || nextBarTime &lt;= qsrc[i].DT) <span class="comment">//next bar completed</span>
<a name="l00777"></a>00777                 {
<a name="l00778"></a>00778                     <span class="keywordflow">if</span> (i &gt; 0)
<a name="l00779"></a>00779                     {
<a name="l00780"></a>00780                         bar.Open = bar.High = bar.Low = bar.Close = qsrc[i - 1].Close;
<a name="l00781"></a>00781                         qdest.Add(bar); <span class="comment">//store existing bar</span>
<a name="l00782"></a>00782                     }
<a name="l00783"></a>00783                     bar = <span class="keyword">new</span> TBar();
<a name="l00784"></a>00784                     bar.Bar = bar.X = j++;
<a name="l00785"></a>00785                     bar.DT = qsrc[i].DT;
<a name="l00786"></a>00786                     bar.Open = bar.High = bar.Low = bar.Close = qsrc[i].Close;
<a name="l00787"></a>00787                 }
<a name="l00788"></a>00788             }
<a name="l00789"></a>00789             qdest.Add(bar); <span class="comment">//store last, possible none completed bar</span>
<a name="l00790"></a>00790             Frames[(int)ctype, destTF] = qdest;
<a name="l00791"></a>00791         }
<a name="l00792"></a>00792 
<a name="l00793"></a>00793         <span class="comment">//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//</span>
<a name="l00799"></a>00799 <span class="comment"></span>        <span class="keywordtype">void</span> fillFramesLine(<span class="keywordtype">double</span>[] quotes_h1, <span class="keywordtype">double</span>[] quotes_d1)
<a name="l00800"></a>00800         {
<a name="l00801"></a>00801             <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a> ctype = <a class="code" href="namespace_chart_v2.html#a813b22baa4da3db343ab2ee8f39c442b">ChartType</a>.Line;
<a name="l00802"></a>00802             <span class="keywordtype">int</span> ct = (int)ctype;
<a name="l00803"></a>00803             <span class="comment">//base 60min plan</span>
<a name="l00804"></a>00804             Frames[ct, H1] = <span class="keyword">new</span> TQuotes(<span class="keyword">this</span>, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.m60, ctype, quotes_h1.Length / 5);
<a name="l00805"></a>00805             <span class="keywordtype">double</span> time_next_H1 = 0;
<a name="l00806"></a>00806             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; quotes_h1.Length / 5; i++)
<a name="l00807"></a>00807             {
<a name="l00808"></a>00808                 <span class="keywordtype">int</span> j = i * 5;       <span class="comment">//set real index of bar in double[] quotes array</span>
<a name="l00809"></a>00809                 TBar b = <span class="keyword">new</span> TBar(); <span class="comment">//local alias of current bar</span>
<a name="l00810"></a>00810                 b.Bar = b.X = i;
<a name="l00811"></a>00811 
<a name="l00812"></a>00812                 <span class="comment">//собираем часовые фреймы из любых исходных</span>
<a name="l00813"></a>00813                 <span class="keywordflow">if</span> (quotes_h1[j + T] &gt;= time_next_H1)
<a name="l00814"></a>00814                 {
<a name="l00815"></a>00815                     <span class="keywordflow">if</span> (priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.log10)
<a name="l00816"></a>00816                         b.Open = b.High = b.Low = b.Close = Math.Log10((<span class="keywordtype">double</span>)GlobalMembersTAmodel.round((decimal)quotes_h1[j + C], Decimals));
<a name="l00817"></a>00817                     <span class="keywordflow">else</span><span class="comment">// if (priceScale == PriceScaleType.linear)</span>
<a name="l00818"></a>00818                         b.Open = b.High = b.Low = b.Close = (double)GlobalMembersTAmodel.round((decimal)quotes_h1[j + C], Decimals);
<a name="l00819"></a>00819 
<a name="l00820"></a>00820                     <span class="keywordflow">if</span> (timeisdouble)
<a name="l00821"></a>00821                         b.DT = nuldate + TimeSpan.FromDays(quotes_h1[j + T]);
<a name="l00822"></a>00822                     <span class="keywordflow">else</span>
<a name="l00823"></a>00823                         b.DT = nuldate + TimeSpan.FromSeconds((uint)quotes_h1[j + T]);
<a name="l00824"></a>00824 
<a name="l00825"></a>00825                     Frames[ct, H1].Add(b);
<a name="l00826"></a>00826                     time_next_H1 = quotes_h1[j + T] + onehour; <span class="comment">//3600 sec == 1 hour</span>
<a name="l00827"></a>00827                 }
<a name="l00828"></a>00828             }
<a name="l00829"></a>00829             <span class="comment">//m240</span>
<a name="l00830"></a>00830             fillFrameLine(H1, H4);
<a name="l00831"></a>00831 
<a name="l00832"></a>00832             <span class="comment">//daily</span>
<a name="l00833"></a>00833             <span class="keywordflow">if</span> (quotes_d1 != null &amp;&amp; quotes_d1.Length &gt; 0) <span class="comment">//(quotes_d1.Length &gt;  quotes_h1.Length / 100) -- актуальный размер массива при котором имеет смысл переходить на дневную истории, иначе, доступная история дневок короче чем часовая</span>
<a name="l00834"></a>00834             {
<a name="l00835"></a>00835                 <span class="comment">//берем дневную историю</span>
<a name="l00836"></a>00836                 Frames[ct, D] = <span class="keyword">new</span> TQuotes(<span class="keyword">this</span>, <a class="code" href="namespacertservice.html#aba4d693ff4feace372fd12fcec2bda3b">TF</a>.Day, ctype, quotes_d1.Length / 5);
<a name="l00837"></a>00837 
<a name="l00838"></a>00838                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; quotes_d1.Length / 5; i++)
<a name="l00839"></a>00839                 {
<a name="l00840"></a>00840                     <span class="keywordtype">int</span> j = i * 5;                <span class="comment">//set real index of bar in double[] quotes array</span>
<a name="l00841"></a>00841                     TBar b = <span class="keyword">new</span> TBar(); <span class="comment">//local alias of current bar</span>
<a name="l00842"></a>00842                     b.Bar = b.X = i;
<a name="l00843"></a>00843                     <span class="keywordflow">if</span> (priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.log10 || priceScale == <a class="code" href="namespace_skilful_1_1_quotes_manager.html#ad2f2ef31f521d8c428ffa09711bb5453">PriceScaleType</a>.mixed)
<a name="l00844"></a>00844                         b.Open = b.High = b.Low = b.Close = Math.Log10((<span class="keywordtype">double</span>)GlobalMembersTAmodel.round((decimal)quotes_d1[j + (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.C], Decimals));
<a name="l00845"></a>00845                     <span class="keywordflow">else</span> <span class="comment">//if (priceScale == PriceScaleType.linear)</span>
<a name="l00846"></a>00846                         b.Open = b.High = b.Low = b.Close = (double)GlobalMembersTAmodel.round((decimal)quotes_d1[j + (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.C], Decimals);
<a name="l00847"></a>00847                     b.DT = <span class="keyword">new</span> DateTime(1970, 01, 01) + TimeSpan.FromSeconds(quotes_d1[j + (<span class="keywordtype">int</span>)<a class="code" href="namespace_skilful_1_1_quotes_manager.html#aa5e2a068f8aede136b7562d485369024">Candle</a>.T]);
<a name="l00848"></a>00848                     Frames[ct, D].Add(b);
<a name="l00849"></a>00849                 }
<a name="l00850"></a>00850             }<span class="keywordflow">else</span>{
<a name="l00851"></a>00851                 fillFrameLine(H4, D);
<a name="l00852"></a>00852             }
<a name="l00853"></a>00853             <span class="comment">//weekly</span>
<a name="l00854"></a>00854             fillFrameLine(D, W);
<a name="l00855"></a>00855             <span class="comment">//mongthly</span>
<a name="l00856"></a>00856             fillFrameLine(D, M);
<a name="l00857"></a>00857             <span class="comment">//quarterly</span>
<a name="l00858"></a>00858             fillFrameLine(M, Q);
<a name="l00859"></a>00859             <span class="comment">//yearly</span>
<a name="l00860"></a>00860             fillFrameLine(Q, Y);
<a name="l00861"></a>00861             <span class="comment">//end</span>
<a name="l00862"></a>00862         }
<a name="l00863"></a>00863     }
<a name="l00864"></a>00864 }
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>Указатель</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Классы</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Пространства имен</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Файлы</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Функции</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Переменные</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Перечисления</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Свойства</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>События</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Создано системой&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
